package com.docted.seckill.service;

import com.docted.seckill.dto.Exposer;
import com.docted.seckill.dto.SeckillExecution;
import com.docted.seckill.entity.Seckill;
import com.docted.seckill.exception.RepeatKillException;
import com.docted.seckill.exception.SeckillCloseException;
import com.docted.seckill.exception.SeckillException;

import java.util.List;

/**
 * Created by DoCted on 2017/5/24
 * Description:
 * 站在"使用者"的角度设计接口
 * 方法定义力度，参数，返回类型(return 类型/异常)
 */
public interface SeckillService {

    /**
     * 查询所有表啥记录
     * @return
     */
    List<Seckill> getSeckillList();

    /**
     * 获取单个秒杀记录
     * @param seckillId
     * @return
     */
    Seckill getSeckillById(Long seckillId);

    /**
     * 秒杀开启输出秒杀接口地址，
     * 否则输出系统时间和秒杀时间
     * @param seckillId
     */
    Exposer exportSeckillUrl(Long seckillId);

    /**
     * 执行秒杀操作
     * @param seckillId
     * @param userPhone
     * @param md5
     */
    SeckillExecution executeSeckill(Long seckillId, Long userPhone, String md5)
            throws RepeatKillException, SeckillCloseException, SecurityException;

    /**
     * 通过存储过程执行秒杀
     * @param seckillId
     * @param userPhone
     * @param md5
     * @return
     */
    SeckillExecution executeSeckillProcedure(Long seckillId, Long userPhone, String md5);

}
